//
//  JXHistoryManager.h
//  JXIntercomSDK
//
//  Created by Nansen on 2020/4/21.
//  Copyright © 2020 jingxi. All rights reserved.
//

#import <Foundation/Foundation.h>

@class JXCallRecordModel;
@class JXVideoRecordModel;
@class JXPicRecordModel;
@class CATiledLayer;

@class JXSecurityRecordModel;
@class JXSecurityAlarmRecordModel;

NS_ASSUME_NONNULL_BEGIN

@protocol JXHistoryDelegate <NSObject>

@optional
#pragma mark ---- 呼叫记录 ----
/// 新增了一条历史记录
- (void)didAddNewCallRecord:(JXCallRecordModel *)callRecord;
/// 更新了一条历史记录
- (void)didUpdateCallRecord:(JXCallRecordModel *)callRecord;
/// 更新了一组记录
- (void)didUpdateCallRecords;
/// 删除了一条历史记录
- (void)didRemoveCallRecord:(JXCallRecordModel *)callRecord;
/// 删除了指定家庭的所有历史记录
- (void)didRemoveCallRecordsInHome:(NSString *)homeId;

#pragma mark ---- 切换安防的记录 ----
/// 新增了一条切换安防的历史记录
- (void)didAddNewSecurityRecord:(JXSecurityRecordModel *)securityRecord;

#pragma mark ---- 警报的记录 ----
/// 新增了一条报警记录. 收到一条报警记录会触发
- (void)didAddNewAlarmRecord:(JXSecurityAlarmRecordModel *)alarmRecord;
/// 更新了一条报警记录. 报警被取消之后会触发
- (void)didUpdateAlarmRecord:(JXSecurityAlarmRecordModel *)alarmRecord;

@end


@interface JXHistoryManager : NSObject

/// 添加代理
- (void)addHistoryDelegateHolder:(id<JXHistoryDelegate>)holder;
/// 移除代理
- (void)removeHistoryDelegateHolder:(id<JXHistoryDelegate>)holder;

#pragma mark - ======== 呼叫历史 ========

/// 获取指定家庭的所有通话记录, 会按照 startTime 倒序,
- (NSArray<JXCallRecordModel *> *)getCallRecordsInHome:(NSString *)homeId;


/// 删除一个视频记录. 如果存在此数据,会触发 didUpdateCallRecord: 方法
- (void)deleteVideoRecord:(JXVideoRecordModel *)videoRecord;
/// 删除一组视频记录. 触发 didUpdateCallRecords 方法
- (void)deleteVideoRecords:(NSArray<JXVideoRecordModel *> *)videoRecords;

/// 删除一个截图记录. 如果中存在此数据,会触发 didUpdateCallRecord: 方法
- (void)deletePicRecord:(JXPicRecordModel *)picRecord;
/// 删除一组截图记录. 触发 didUpdateCallRecords 方法
- (void)deletePicRecords:(NSArray<JXPicRecordModel *> *)picRecords;

/// 删除一个通话记录. 触发 didRemoveCallRecord: 方法
- (void)deleteCallRecord:(JXCallRecordModel *)callRecord;
/// 删除一组通话记录. 触发 didUpdateCallRecords 方法
- (void)deleteCallRecords:(NSArray<JXCallRecordModel *> *)callRecords;

/// 删除一个家庭的所有通话记录. 触发 didRemoveCallRecordsInHome 方法
- (void)deleteCallRecordWithHomeId:(NSString *)homeId;


#pragma mark - ======== 安防历史 ========
/// 获取指定 homeId 的安防切换记录。(按照 switchTime 倒序)
- (NSArray<JXSecurityRecordModel *> *)getSecurityRecordsInHome:(NSString *)homeId;
/// 删除一组安防切换的记录
- (void)deleteSecurityRecordArray:(NSArray<JXSecurityRecordModel *> *)securityRecords;

#pragma mark - ======== 警报历史 ========
/// 获取指定 homeId 的警报历史记录. (按照 receivedTime 倒序)
- (NSArray<JXSecurityAlarmRecordModel *> *)getSecurityAlarmRecordsInHome:(NSString *)homeId;
/// 删除一组警报的记录
- (void)deleteAlarmRecordArray:(NSArray<JXSecurityAlarmRecordModel *> *)alarmRecords;

@end

NS_ASSUME_NONNULL_END
